<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2"/>
    <g:set var="entityName" value="${message(code: 'note.label', default: 'note')}"/>
    <title>编辑笔记</title>
</head>

<body>
<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>编辑笔记</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item">
                        <g:link controller="note" action="index">笔记列表</g:link>
                    </li>
                    <li class="breadcrumb-item">编辑笔记</li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
            <g:if test="${flash.message}">
                <div class="message" role="status">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${this.note}">
                <ul class="errors" role="alert">
                    <g:eachError bean="${this.note}" var="error">
                        <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
                                error="${error}"/></li>
                    </g:eachError>
                </ul>
            </g:hasErrors>
            <div class="card">
                <div class="card-header">
                    <h5>编辑笔记</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">
                    <g:form resource="${this.note}" method="PUT">
                        <g:textField class="hidden" name="targetUri" value="${targetUri}"></g:textField>
                        <div class="form-group row">
                            <label class="col-md-2 control-label is-required">主题</label>

                            <div class="col-md-8">
                                <g:textField name="subject" class="form-control" value="${this.note?.subject}"/>
                            </div>

                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group row">
                            <g:field name="text" id="text" value="${this.note?.text}" type="hidden"/>
                            <label class="col-md-2 control-label is-required">内容</label>
                            <div class="col-md-8">
                                <div id="noteText">${this.note?.text}</div>
                            </div>
                        </div>

                        <div class="hide">
                            <g:select class="form-control hide" name="activity.id" value="${this.note?.activity?.id}" from="${com.next.Activity.list()}" optionKey="id" optionValue="name" noSelection="${['': '请选择']}"></g:select>
                            <g:select class="form-control hide" name="user.id" value="${this.note?.user?.id}" from="${com.next.User.list()}" optionKey="id" optionValue="fullName" noSelection="${['': '请选择']}"></g:select>
                            <g:select class="form-control hide" name="asset.id" value="${this.note?.asset?.id}" from="${com.next.Asset.list()}" optionKey="id" optionValue="name" noSelection="${['': '请选择']}"></g:select>
                            <g:select class="form-control hide" name="account.id" value="${this.note?.account?.id}" from="${com.next.Account.findAllByActive(true)}" optionKey="id" optionValue="name" noSelection="${['': '请选择']}"></g:select>
                            <g:select class="form-control hide" name="contact.id" value="${this.note?.contact?.id}" from="${com.next.Contact.findAllByActive(true)}" optionKey="id" optionValue="fullName" noSelection="${['': '请选择']}"></g:select>
                            <g:select class="form-control hide" name="campaign.id" value="${this.note?.campaign?.id}" from="${com.next.Campaign.findAllByActive(true)}" optionKey="id" optionValue="name" noSelection="${['': '请选择']}"></g:select>
                            <!-- <g:select class="form-control hide" name="opportunity.id" value="${this.note?.opportunity?.id}" from="${com.next.Opportunity.list()}" optionKey="id" optionValue="id" noSelection="${['': '请选择']}"></g:select> -->
                            <g:select class="form-control hide" name="opportunity.id" value="${this.note?.opportunity?.id}" from="${com.next.OpportunityTeam.findAllByUser(this?.user)}" optionKey="opportunityId" optionValue="opportunity" noSelection="${['': '请选择']}"></g:select>
                        </div>

                        <div class="form-group row">
                            <div class="col-md-12">
                                <button class="btn btn-info"  id="submitButton">保存</button>
                            </div>
                        </div>
                    </g:form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        var text = $("#text").val();
        $('#noteText').summernote({
            minHeight: 400,
            maxHeight: 600,

        }).summernote('code', text);

        $("#submitButton").click(function () {
            var noteText = $('#noteText').summernote('code');
            $("#text").val(noteText);
        });
    })
</script>

</body>

</html>


